package com.gzz.orchid.common.core.definition;

import com.gzz.orchid.common.core.support.IBaseEnum;

/**
 * 用户状态
 *
 * @author higmd
 */
public enum UserStatus implements IBaseEnum {
    NEW(0, "新增"), ACTIVE(1, "生效"), LOCKED(2, "锁定"), FORBIDEN(3, "禁用"), DESTROY(99, "销户");

    private final int code;
    private final String text;

    UserStatus(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static UserStatus parse(int val) {
        for (UserStatus e : UserStatus.values()) {
            if (e.code == val) {
                return e;
            }
        }
        throw new IllegalArgumentException("Invalid UserStatus value: " + val);
    }

    public static UserStatus of(String name) {
        return Enum.valueOf(UserStatus.class, name);
    }

    @Override
    public Integer getValue() {
        return this.code;
    }

    @Override
    public String getLabel() {
        return this.text;
    }
}
